<?php
namespace Common\Model;
use Think\Model;

class UserClubModel extends Model {

    /**
     * model的中文名称
     */
    public $modelName = '旅社';

    /**
     * model的icon
     */
    public $modelIcon = 'icon-building';
	
	protected $_auto = [
		["create_time", "time", 1, "function"],
		["update_time", "time", 2, "function"],
	];
	protected $_validate = [
		["id", "require", "ID必须填写!"],
		["principal_id", "require", "用户ID必须填写!"],
		["club_name", "require", "旅行社名称必须填写!"],
		["address", "require", "旅行社地址必须填写!"],
		["service_area", "require", "服务地区必须填写!"],
		["bussiness", "require", "业务范围必须填写!"],
		["tel", "require", "电话必须填写!"],
		["justification", "require", "营业执照必须填写!"],
		["create_time", "require", "创建时间必须填写!"],
		["update_time", "require", "更新时间必须填写!"],
	];
	public $excel = false;
	public $delete = false;
	public $fieldMap = [
		"id" => [
			"type" => "input",
			"name" => "ID",
			"show" => true,
			"search" => true,
			"input" => false,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => "",
		],
		"principal_id" => [
			"type" => "input",
			"name" => "用户名",
			"show" => true,
			"search" => true,
			"input" => 'create',
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => '<td class="center"><a href="{:U(\'user/list\')}?searchMap[id]={$vo[principal_id]}"><php>echo D(\'User\')->find($vo[principal_id])[\'username\'];</php></a></td>',
		],
		"club_name" => [
			"type" => "input",
			"name" => "旅行社名称",
			"show" => true,
			"search" => true,
			"input" => true,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => "",
		],
		"address" => [
			"type" => "input",
			"name" => "旅行社地址",
			"show" => true,
			"search" => false,
			"input" => true,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => "",
		],
		"service_area" => [
			"type" => "foreign",
			"name" => "服务地区",
			"show" => true,
			"search" => false,
			"input" => true,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "region,id,name,select",
			"list_specify" => "",
		],
		"bussiness" => [
			"type" => "input",
			"name" => "业务范围",
			"show" => true,
			"search" => false,
			"input" => true,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => '<td class="center">
			<php>
			$bussinessStr = "";
			$bussinessArr = explode(",", $vo[\'bussiness\']);
			foreach ($bussinessArr as $v) {
				$bussinessStr .= D("FundingType")->find($v)["long_name"].",";
			}
			$bussinessStr = rtrim($bussinessStr, ",");
			</php>
			{$bussinessStr}
			</td>',
            "update_specify"=>'
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right" for="bussiness"> 业务范围 </label>
                <div class="col-xs-12 col-sm-6">
                    <span class="block input-icon input-icon-right" style="padding-top:0.2rem;">
                        <php>$fundingType = D("FundingType")->select();</php>
                        <volist name="fundingType" id="vo">
                            <label><input type="checkbox" value="{$vo[\'id\']}" name="bussiness[]" id="bussiness[]" <if condition="strstr($model[\'bussiness\'], $vo[\'id\'])" > checked</if> />{$vo[\'long_name\']} &nbsp;&nbsp;</label>
                        </volist>
                        <i class=""></i>
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline" style="margin-bottom: 5px;"></div>
             </div>
            ',

		],
		"tel" => [
			"type" => "input",
			"name" => "电话",
			"show" => true,
			"search" => false,
			"input" => true,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => "",
		],
		"justification" => [
			"type" => "file",
			"name" => "营业执照",
			"show" => false,
			"search" => false,
			"input" => true,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => '<td class="center"><img src="__PUBLIC__/file/{$detail[justification]}" width="80" height="50"/></td>',
		],
		"create_time" => [
			"type" => "datetime",
			"name" => "创建时间",
			"show" => false,
			"search" => false,
			"input" => false,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => "",
		],
		"update_time" => [
			"type" => "datetime",
			"name" => "更新时间",
			"show" => false,
			"search" => false,
			"input" => false,
			"required" => true,
			"detail" => true,
			"excel" => true,
			"content" => "",
			"list_specify" => "",
		],
	];
}
